package com.wudimeng.syll.utils;

import com.github.pagehelper.PageInfo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

//分页工具类
public class Page {

	//获取PageInfo中的分页信息
	public static Map<String, Object> getPageMap(List<Map<String, Object>> paramList){
	    if(paramList == null || paramList.size() == 0) {
	        return null;
        }
		PageInfo<Map<String, Object>> pageInfo = new PageInfo<Map<String, Object>>(paramList);
		Map<String, Object> pageMap = new HashMap<String, Object>();
		pageMap.put("count", pageInfo.getSize());
		pageMap.put("counts", pageInfo.getTotal());
		pageMap.put("page", pageInfo.getPageNum());
		pageMap.put("pages", pageInfo.getPages());
		return pageMap;
	}

	//获取PageInfo中的分页信息
    public static Map<String, Object> getPageObject(List paramList){
        if(paramList == null || paramList.size() == 0) {
            return null;
        }
        PageInfo pageInfo = new PageInfo(paramList);
        Map<String, Object> pageMap = new HashMap<String, Object>();
        pageMap.put("count", pageInfo.getSize());
        pageMap.put("counts", pageInfo.getTotal());
        pageMap.put("page", pageInfo.getPageNum());
        pageMap.put("pages", pageInfo.getPages());
        return pageMap;
    }
}
